package cn.edu.ctbu.eol.teacher.common;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class GlobalExceptionHandler {

    @ExceptionHandler(Exception.class)
    public Result<String> exceptionHandler(Exception ex){
        log.error("异常信息：{}", ex.getMessage());
        return Result.error("系统繁忙，请稍后再试");
    }

    @ExceptionHandler(CustomException.class)
    public Result<String> customExceptionHandler(CustomException ex){
        log.error("异常信息：{}", ex.getMessage());
        return Result.error(ex.getMessage());
    }
} 